package com.jzo2o.foundations.config;


import lombok.extern.slf4j.Slf4j;
import org.apache.http.HttpHost;
import org.elasticsearch.client.RestClient;
import org.elasticsearch.client.RestHighLevelClient;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * \* User: chy
 * \* Date: 2025/9/29  14:25
 * \* Description:
 * \
 */
@Configuration
@Slf4j
public class EsConfig {
    @Value("${jzo2o.es.host}")
    private String host;
    @Value("${jzo2o.es.port}")
    private int port;

    @Bean
    public RestHighLevelClient esClient(){
        return new RestHighLevelClient(RestClient.builder(
                new HttpHost(
                        host,
                        port,
                        "http"
                )
        ));
    }
}
